﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Pseudogenerator.Common.Generators;
using Pseudogenerator.Common.ViewModels.Core;

namespace Pseudogenerator.Common.ViewModels
{
    public class ImporterViewModel
        : WorkSpaceViewModel<Importer>
    {

        public ImporterViewModel()
        {
            ModeloActual = new Importer();
        }

        #region ModelFields

        public string x0
        {
            get
            {
                return ModeloActual.x0;
            }
            set
            {
                if (ModeloActual.x0 == value)
                    return;
                ModeloActual.x0 = value;
                OnPropertyChanged();
                RefreshGUI();
            }
        }

        #endregion

        public override bool CanRun
        {
            get
            {
                return !InWorkProgress && ModeloActual.CanGenerateNext;
            }
        }

        private Importer _ModeloActual = null;
        public override Importer ModeloActual
        {
            get
            {
                if (_ModeloActual == null)
                    _ModeloActual = new Importer();

                return _ModeloActual;
            }
            set
            {
                if (value == null)
                    return;
                this.x0 = value.x0;
                ClearCommand.Execute(null);
            }
        }

        public override string Title
        {
            get { return "Importador de texto"; }
        }

        public override IEnumerable<string> Errors
        {
            get 
            {
                if (string.IsNullOrWhiteSpace(x0))
                {
                    yield return "Debe establecer el texto de origen de importacion 'x0'";
                }
            }
        }

        public override IEnumerable<string> Recommendations
        {
            get { return new List<string>();}
        }

        protected override void AddPreload()
        {
            
        }
    }
}
